#include "OoO/core.h"

namespace config
{
    const Switch UseIdealFrontend = {"UseIdealFrontend", "use IdealFrontend"};
    const Switch UseIdealBackend = {"UseIdealBackend", "use IdealBackend"};
} // namespace config


OoOCore::OoOCore()
{
    if(config::UseIdealFrontend) {
        frontend = new IdealFrontend();
    } else {
        frontend = new NormalFrontend();
    }

    if(config::UseIdealBackend) {
        backend = new IdealBackend();
    } else {
        backend = new OoOBackend();
    }

    backend->frontend = frontend;
    backend->cache = &cache;
    cache.recv = backend;
}
OoOCore::~OoOCore()
{
}
void OoOCore::run()
{
    cache.run();
    backend->run();
    frontend->run();
}
void OoOCore::reset()
{
    cache.reset();
    backend->reset();
    frontend->reset();
}
void OoOCore::print_counter()
{
    frontend->print_counter();
    float ipc = (float)backend->inst_cnt / backend->cycle;
    printf(COLOR("[OoOCore] ", GREEN) "IPC:%.03f\n", ipc);
}
void OoOCore::print_status()
{
    frontend->print_status();
}
